package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.simple.ProjectEntrySimple;
import com.nbsaas.boot.project.data.entity.ProjectEntry;
import com.nbsaas.boot.rest.api.Converter;

/**
 * -列表对象转换器
 */

public class ProjectEntrySimpleConvert implements Converter<ProjectEntrySimple, ProjectEntry> {


    @Override
    public ProjectEntrySimple convert(ProjectEntry source) {
        ProjectEntrySimple result = new ProjectEntrySimple();

        result.setName(source.getName());

        try {
            if (source.getProject() != null) {
                result.setProject(source.getProject().getId());
            }
        } catch (Exception ignored) {
        }

        result.setId(source.getId());

        try {
            if (source.getProject() != null) {
                result.setProjectName(source.getProject().getName());
            }
        } catch (Exception ignored) {
        }

        result.setAddDate(source.getAddDate());
        result.setLastDate(source.getLastDate());


        return result;
    }

}